#include <stdio.h>
#include <GL/glut.h>
#include "vector3D.h"
#include <iostream>
#include "Mouse.h"
#include "Camera.h"
#include "RealTimeLoop.h"
#include "Achievement.h"

#include "LevelSwitcher.h"

#include "GameMenu.h"
#include "Sound.h"

#include "FreeType.h"

#define MAX_WEP_LEVEL	5

#define	MATREQ_SNS		5
#define MATREQ_GS		5
#define MATREQ_DS		5
#define MATREQ_POT		2

#define MATREQ_ITEM_SNS	Item::SWORDPIECE
#define MATREQ_ITEM_GS	Item::ARROWHEAD
#define MATREQ_ITEM_DS	Item::LEATHER
#define MATREQ_ITEM_POT	Item::LEATHER

class myApplication 
{
public:
	// this is a constructor, it is implemented in myapplication.cpp
	myApplication();
	// this is a destructor, it is implemented in myapplication.cpp
	~myApplication();

//	bool Start( int argc, char **argv );

	bool Init();

	void renderScene(void);

	void changeSize(int w, int h);

	void SpecialInputKeyDown(int key, int x, int y);
	void SpecialInputKeyUp(int key, int x, int y);
	void KeyboardDown(unsigned char key, int x, int y);
	void KeyboardUp(unsigned char key, int x, int y);
	void MouseMove (int x, int y);
	void MouseClick(int button, int state, int x, int y);

	static myApplication* getInstance();
	void Drop();

private:
	
	static myApplication *s_pInstance;

	// splash screen
	TextureImage splash;
	TextureImage loading;

	int track_loading;
	bool track_loading_done;
	bool LoadAll(void);

	LevelSwitcher *theLevels;

	// Camera
	Vector3D theCameraPosition;
	Vector3D theCameraDirection;
	float angle;

	void Update(void);

	//void RenderHero(void);

	//  The number of frames
	int frameCount;
	//  Number of frames per second
	float fps;
	//  currentTime - previousTime is the time elapsed
	//  between every call of the Idle function
	int currentTime, previousTime;
	// Calculate the FPS
	void calculateFPS();
	// Display FPS
	void drawFPS(freetype::font_data font);

	freetype::font_data our_font;

	// realtime loop control
	CRealTimeLoop* theRTL;

	bool myKeys[255];
	MouseInfo *mouseInfo;

	// The camera
	Camera* theCamera;

	// The Game Menu
	CGameMenu* theGameMenu;

	// The Sound
	Sound* theSound;
};